load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
    # Keep sorted.
    "//packages/ic-ed25519",
    "//packages/ic-secp256k1",
    "//packages/icrc-ledger-types:icrc_ledger_types",
    "//rs/ledger_suite/icp:icp_ledger",
    "//rs/nns/governance/api",
    "//rs/rosetta-api/common/rosetta_core:rosetta-core",
    "//rs/rosetta-api/icp:ic-rosetta-api",
    "//rs/rosetta-api/icp:rosetta-api",
    "//rs/types/base_types",
    "@crate_index//:anyhow",
    "@crate_index//:candid",
    "@crate_index//:hex",
    "@crate_index//:num-bigint",
    "@crate_index//:reqwest",
    "@crate_index//:serde",
    "@crate_index//:tokio",
    "@crate_index//:url",
]

DEV_DEPENDENCIES = [
    # Keep sorted.
    ":ic-icp-rosetta-client",
    "//packages/pocket-ic:pocket-ic",
    "//rs/ledger_suite/icp:icp_ledger",
    "//rs/nns/constants",
    "//rs/rosetta-api/icp/runner:ic-icp-rosetta-runner",
    "//rs/rosetta-api/icp/test_utils",
    "@crate_index//:candid",
    "@crate_index//:tempfile",
    "@crate_index//:tokio",
]

rust_library(
    name = "ic-icp-rosetta-client",
    srcs = ["src/lib.rs"],
    crate_name = "ic_icp_rosetta_client",
    deps = DEPENDENCIES,
)

rust_test(
    name = "ic-icp-rosetta-client-tests",
    srcs = ["tests/tests.rs"],
    data = [
        "//rs/canister_sandbox",
        "//rs/canister_sandbox:sandbox_launcher",
        "//rs/ledger_suite/icp/ledger:ledger-canister-wasm",
        "//rs/pocket_ic_server:pocket-ic-server",
        "//rs/replica",
        "//rs/rosetta-api/icp:ic-rosetta-api-rosetta-blocks",
    ],
    env = {
        "CANISTER_LAUNCHER": "$(rootpath //rs/canister_sandbox)",
        "POCKET_IC_BIN": "$(rootpath //rs/pocket_ic_server:pocket-ic-server)",
        "REPLICA_BIN": "$(rootpath //rs/replica)",
        "ROSETTA_BIN_PATH": "$(rootpath //rs/rosetta-api/icp:ic-rosetta-api-rosetta-blocks)",
        "SANDBOX_LAUNCHER": "$(rootpath //rs/canister_sandbox:sandbox_launcher)",
        "LEDGER_CANISTER_WASM_PATH": "$(rootpath //rs/ledger_suite/icp/ledger:ledger-canister-wasm)",
    },
    deps = DEV_DEPENDENCIES,
)
